package com.d3works.apps.account.service.fixedasset;

import com.d3works.apps.account.db.FixedAsset;
import com.d3works.apps.account.db.FixedAssetLine;
import com.d3works.apps.account.db.TaxLine;
import com.d3works.apps.base.db.Batch;
import com.d3works.exception.D3worksException;
import java.math.BigDecimal;
import java.time.LocalDate;

public interface FixedAssetLineMoveService {

  void realize(FixedAssetLine fixedAssetLine, boolean isBatch, boolean generateMove)
      throws D3worksException;

  /**
   * This method will generate a disposal move on fixedAsset at disposalDate. The move will have 2
   * or 3 move lines, depending on value of fixedAssetLine. (it can be null)
   *
   * @param fixedAsset
   * @param fixedAssetLine
   * @param transferredReason
   * @param disposalDate
   * @throws D3worksException
   */
  void generateDisposalMove(
      FixedAsset fixedAsset,
      FixedAssetLine fixedAssetLine,
      int transferredReason,
      LocalDate disposalDate)
      throws D3worksException;

  /**
   * Method that may computes action "realize" on lines of fiscalFixedAssetLineList,
   * fixedAssetLineList and fixedAssetDerogatoryLineList that matches the same depreciation date. It
   * will compute depending on the fixedAsset.depreciationPlanSelect
   *
   * @param fixedAsset
   * @param depreciationDate
   * @throws D3worksException
   */
  void realizeOthersLines(
      FixedAsset fixedAsset, LocalDate depreciationDate, boolean isBatch, boolean generateMove)
      throws D3worksException;

  void generateSaleMove(
      FixedAsset fixedAsset, TaxLine taxLine, BigDecimal disposalAmount, LocalDate disposalDate)
      throws D3worksException;

  /**
   * Method that only create a move on fixed asset line.
   *
   * @param fixedAssetLine
   * @throws D3worksException
   */
  void simulate(FixedAssetLine fixedAssetLine) throws D3worksException;

  /**
   * Method that only create a move all move lines of fixed asset that matches depreciationDate.
   *
   * @param fixedAssetLine
   * @throws D3worksException
   */
  void simulateOthersLine(FixedAsset fixedAsset, LocalDate depreciationDate)
      throws D3worksException;

  /**
   * Method that checks if fixedAssetLine can be simulated or not.
   *
   * @param fixedAssetLine
   * @return true if it can be simulated. false otherwise
   * @throws D3worksException
   */
  boolean canSimulate(FixedAssetLine fixedAssetLine) throws D3worksException;

  /**
   * When calling service from a batch, it might be necessary to set batch to attach generated moves
   * to batch
   *
   * @param batch
   */
  void setBatch(Batch batch);
}
